home *** CD-ROM | disk | FTP | other *** search
- /* InitWWJr.c
- * Initialization code for Writeswell Jr.
- *
- * ©1992 Working Software, Inc.
- * This source code is copyrighted. Permission is granted to use the Word Services
- * portion of the Writeswell Jr. source code in your own programs, but you
- * may not distribute the Writeswell Jr. word-processor code as a
- * commercial product. If you modify the code, please do not call it
- * Writeswell Jr. (or Writeswell.) This will ensure that people understand the
- * program and don’t have to deal with a number of different versions with
- * who-knows-what going on in the code.
- *
- * Writeswell Jr. and Writeswell are trademarks of Working Software, Inc.
- */
-
- #include <EPPC.h>
- #include <AppleEvents.h>
- #include "GenHandlers.h"
- #include "AppEvents.h"
- #include "InitMenu.h"
- #include "Gripe.h"
- #include "AEObj.h"
- #include "MyFiles.h"
- #include "InitWWJr.h"
-
- OSErr CheckApplParams( SFReply *replyPtr );
-
- OSErr InitForSystem7( void )
- {
- OSErr err;
-
- PutUpSys7Menus();
-
- if ( err = InitReqHandlers() )
- return err;
-
- if ( err = InitGenericHandlers() )
- return err;
-
- if ( err = InitAEObjStuff() )
- return err;
-
- return noErr;
- }
-
- OSErr TearDown( void )
- {
- OSErr err;
-
- // The particular routines we call here are only for PowerPC, but
- // the function could be used in general for any case of termination.
-
- #ifdef GENERATINGCFM
- err = TearDownReqHandlers();
- if ( err )
- return err;
-
- err = TearDownGenerichandlers();
- if ( err )
- return err;
-
- err = TearDownAEObjStuff();
- if ( err )
- return err;
-
- #endif
- return noErr;
- }
-
- #ifndef GENERATINGCFM
- // This stuff won't compile under PowerPC
-
- OSErr InitForSystem6( void )
- {
- OSErr err;
- SFReply reply;
-
- PutUpSys6Menus();
-
- CheckApplParams( &reply );
-
- if ( reply.good ){
- err = MyOpenSfFile( &reply );
- }else{
- err = MakeNewWindow();
- }
-
- return err;
- }
-
- OSErr CheckApplParams( SFReply *replyPtr )
- {
- short message;
- short count;
- short i;
- AppFile file;
- short vRef;
- ParamBlockRec fPB;
- OSErr err;
-
- replyPtr->good = false;
-
- CountAppFiles(&message,&count);
- if (!count)
- return noErr;
-
- err = GetVol(0L,&vRef);
- if ( err ){
- Gripe( "\pGetVol failed" );
- return err;
- }
-
-
- /* Loop through all the files that were selected on the desktop,
- skipping all that don't have a type of 'TEXT' or 'ttro' */
- for (i = 1; i <= count; i++)
- {
- GetAppFiles(i, &file);
-
- /* If it’s not a file type we can open, skip it */
- switch ( file.fType ){
- case 'TEXT':
- case 'ttro':
-
- fPB.fileParam.ioCompletion = (IOCompletionUPP)NULL;
- fPB.fileParam.ioNamePtr = (StringPtr)NULL;
- fPB.fileParam.ioVRefNum = file.vRefNum;
-
- err = PBSetVol( &fPB, false );
- if ( err ){
- Gripe( "\pPBSetVol failed in MyOpenSpecFile" );
- return err;
- }
-
- replyPtr->vRefNum = file.vRefNum;
- replyPtr->fType = file.fType;
- replyPtr->version = file.versNum;
- BlockMove( file.fName, replyPtr->fName, (file.fName)[0] + 1 );
- replyPtr->copy = false;
- replyPtr->good = true;
-
- return noErr;
- break;
-
- default:
- ClrAppFiles(i);
- break;
- }
- }
-
- return noErr;
- }
- #endif